home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01b.txt
/
000170_icon-group-sender_Fri Nov 9 13:04:28 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id fA9K3lc08843
for icon-group-addresses; Fri, 9 Nov 2001 13:03:47 -0700 (MST)
Message-Id: <200111092003.fA9K3lc08843@baskerville.CS.Arizona.EDU>
Date: Fri, 09 Nov 2001 08:45:33 -0700
From: Steve Wampler <swampler@noao.edu>
X-Accept-Language: en
To: Taybin Rutkin <trutkin@physics.clarku.edu>, icon-group@cs.arizona.edu
Subject: Re: mutual evaluation
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1737
Steve Wampler wrote, apparently w/o thinking:
>
> The expression syntax:
>
> expr0(expr1,expr2,...,exprN)
>
> has a couple of uses. If expr0 evaluates to a function or procedure name
> then that function/procedure is invoked (after evaluating the arguments
> of course!). If expr0 evaluates to an integer, then the arguments are
> evaluated and the whole expression returns the result produced by the argument
> in the position represented by that integer. [Since expr0 evaluates to
> a "position", 0 means to produce the result of the last argument and
> omitting expr0 defaults it to 0.]
Sigh, as was kindly pointed out to me, the last sentence is simply wrong.
When expr0 produces an integer, that integer is treated as identifying
the position of the argument whose value is to be produced. As such it follows
the same rules as other positions (e.g. lists and strings). That means a value
of 0 references a non-existant position "one-off" the end of the list of
expressions. So, omitting expr0 defaults to -1, not 0, and 0(expr1,expr2,expr3)
is equivalent to
expr1 & expr2 & expr3 & &fail
For example, the following program:
procedure main(args)
every i := -3 to 3 do
write(i, ": ", i("a", "b", "c") | "failed")
end
outputs:
-3: a
-2: b
-1: c
0: failed
1: a
2: b
3: c
Finally, if you want the result of the last expression, you can write
either:
(expr1, expr2, ...., exprN)
or
(-1)(expr1, expr2, ...., exprN)
but
-1(expr1, expr2, ...., exprN)
won't work as you might expect, because of precedence rules.
My thanks to Steve Hunter for catching this!
--
Steve Wampler- SOLIS Project, National Solar Observatory
swampler@noao.edu